package com.snowj.apaas.repository.auto;

import static com.snowj.apaas.repository.auto.GroupAuthoritiesDynamicSqlSupport.*;

import com.snowj.apaas.domain.auto.GroupAuthorities;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface GroupAuthoritiesMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255568+08:00", comments="Source Table: group_authorities")
    BasicColumn[] selectList = BasicColumn.columnList(groupId, authority);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.25476+08:00", comments="Source Table: group_authorities")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.254803+08:00", comments="Source Table: group_authorities")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.254846+08:00", comments="Source Table: group_authorities")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<GroupAuthorities> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.254891+08:00", comments="Source Table: group_authorities")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<GroupAuthorities> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.254944+08:00", comments="Source Table: group_authorities")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("GroupAuthoritiesResult")
    Optional<GroupAuthorities> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255005+08:00", comments="Source Table: group_authorities")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="GroupAuthoritiesResult", value = {
        @Result(column="group_id", property="groupId", jdbcType=JdbcType.BIGINT),
        @Result(column="authority", property="authority", jdbcType=JdbcType.VARCHAR)
    })
    List<GroupAuthorities> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255087+08:00", comments="Source Table: group_authorities")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.25513+08:00", comments="Source Table: group_authorities")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, groupAuthorities, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255187+08:00", comments="Source Table: group_authorities")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, groupAuthorities, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.25523+08:00", comments="Source Table: group_authorities")
    default int insert(GroupAuthorities record) {
        return MyBatis3Utils.insert(this::insert, record, groupAuthorities, c ->
            c.map(groupId).toProperty("groupId")
            .map(authority).toProperty("authority")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255294+08:00", comments="Source Table: group_authorities")
    default int insertMultiple(Collection<GroupAuthorities> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, groupAuthorities, c ->
            c.map(groupId).toProperty("groupId")
            .map(authority).toProperty("authority")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255363+08:00", comments="Source Table: group_authorities")
    default int insertSelective(GroupAuthorities record) {
        return MyBatis3Utils.insert(this::insert, record, groupAuthorities, c ->
            c.map(groupId).toPropertyWhenPresent("groupId", record::getGroupId)
            .map(authority).toPropertyWhenPresent("authority", record::getAuthority)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255614+08:00", comments="Source Table: group_authorities")
    default Optional<GroupAuthorities> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, groupAuthorities, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255685+08:00", comments="Source Table: group_authorities")
    default List<GroupAuthorities> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, groupAuthorities, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255733+08:00", comments="Source Table: group_authorities")
    default List<GroupAuthorities> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, groupAuthorities, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.25578+08:00", comments="Source Table: group_authorities")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, groupAuthorities, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255824+08:00", comments="Source Table: group_authorities")
    static UpdateDSL<UpdateModel> updateAllColumns(GroupAuthorities record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(groupId).equalTo(record::getGroupId)
                .set(authority).equalTo(record::getAuthority);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2021-01-10T12:57:45.255895+08:00", comments="Source Table: group_authorities")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(GroupAuthorities record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(groupId).equalToWhenPresent(record::getGroupId)
                .set(authority).equalToWhenPresent(record::getAuthority);
    }
}